// -----------------------------
// Author: 		Dhaenens Gert 
// Creation: 	8/2/2013 7:19:04 PM				
// -----------------------------

#ifndef _LuaError_h
#define _LuaError_h

#include "ObjectLuaDef.h"

struct lua_State;

namespace ObjectLua
{

	/*
	//	Lua Error Policy
	//		- Default: Throws LuaException on error
	//					containing a message about the error
	//		- NoThrow:	Does not throw any errors
	//					Used for silent excecution
	*/
	enum ErrorPolicy
	{
		Default,
		NoThrow,
	};

	/*
	// Lua Error Handler
	*/
	class OBJECTLUA LuaError
	{
	public:

		/*
		// Set the Error Policy for the Lua Error Handling
		// @ ePolicy : The policy to use
		*/
		static void	setPolicy(ErrorPolicy ePolicy);

		/*
		// Handle a Lua Error
		// according to the chosen policy
		// @ lpLua : pointer to Lua Object
		*/
		static void	handleError(lua_State* lpLua);

		/*
		//	Get a Stack Trace
		//	@ lpLua : pointer to Lua Object
		*/
		static const char* stackTrace(lua_State* lpLua);

	private:

		static ErrorPolicy	s_ErrorPolicy;

		LuaError();
		~LuaError();
		LuaError(const LuaError& refLuaError);
		LuaError& operator=(const LuaError& refLuaError);
	};

}

#endif